/**
 * @author Administrator
 */
$(function(){
	 $("#form").validate({
        errorPlacement: function(error, element){
            error.appendTo(element.parent());
        },
        rules: {
            "friendID": {
                required: true,
				minlength:4,
			     remote: {
                    url: "/forum/members/checkfriendId", //后台处理程序
                    type: "post", //数据发送方式
                    dataType: "json", //接受数据格式
                    data: { //要传递的数据
                        friendId: function(){
                            return $("#friendID").val();
                        }
                    }
                }
            },
            "remark": {
				required:true,
				maxlength:10
            }
        },
        messages: {
            "friendID": {
                required: "friendId必填",
				minlength:"长度不得小于{0}",
			     remote:"用户名不存在,或者您已经添加该好友"
            },
            "remark": {
				required:"备注必填",
				maxlength:"长度不得大于{0}"
            }
        }
    });
});
